import 'package:json_annotation/json_annotation.dart';
part 'msg.g.dart';

@JsonSerializable()
class MallChatMessage {
  final int id; // 消息ID
  final int sessionId; // 会话ID
  final int shopId; // 商家ID
  final int userId; // 用户ID
  final String senderRole; // 发送方角色
  final String contentType; // 内容类型
  final String content; // 内容或文本
  final String? mediaUrl; // 媒体地址(可空)
  final bool isRead; // 对端是否已读
  final int receiveUid;
  final DateTime? createdAt; // 创建日期
  final DateTime? updatedAt; // 修改时间
  final DateTime? deletedAt; // 删除时间

  MallChatMessage({
    required this.id,
    required this.sessionId,
    required this.shopId,
    required this.userId,
    required this.senderRole,
    required this.contentType,
    required this.content,
    required this.receiveUid,
    this.mediaUrl,
    this.isRead = false,
    this.createdAt,
    this.updatedAt,
    this.deletedAt,
  });

  factory MallChatMessage.fromJson(Map<String, dynamic> json) =>
      _$MallChatMessageFromJson(json);
  Map<String, dynamic> toJson() => _$MallChatMessageToJson(this);
}
